<?php
if(!isset($_GET['StudentID'])){
    header("location:Students.php"); //跳转到注册页面
}else{
    $StudentID = $_GET['StudentID'];
    
    require 'Conn.php';
    $sql="DELETE FROM student WHERE StudentID=?"; //参数以？代替
    $stmt=$db->prepare($sql); //预处理
    $stmt->bind_param('s',$StudentID); //绑定参数
    $result=$stmt->execute(); //执行查询

    if($result){
        echo "<script>alert('删除成功！');location='Students.php';</script>";
    }else{
        echo "<script>alert('删除失败！');location='Students.php';</script>";
    }
    $db->close();
}